package com.atguigu.gmall.product.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.product.service.FileUploadService;
import com.sun.xml.internal.messaging.saaj.packaging.mime.internet.MimeMultipart;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author 卡尼奶
 * @Date 2022/5/18 18:34
 * @Version 1.0
 */
@RestController
@RequestMapping("/admin/product")
@Slf4j
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    @PostMapping("/fileUpload")
    public Result fileUpload(MultipartFile file) throws Exception {
        log.info("文件名：{},文件大小：{}",file.getOriginalFilename(),file.getSize());
        String path = fileUploadService.fileUpload(file);
        return Result.ok(path);
    }
}
